<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

    /**
     * Constructor de la clase makinita.
     * @param array $entrada
     * @param array $reglas
     * @return boolean $error
     */

     
class sfThSortable extends sfTh {
    
    /**
     * Constructor.
     *
     * Available options:
     *
     *  * id_format:       The format for the generated HTML id attributes (%s by default)
     *  * is_hidden:       true if the form widget must be hidden, false otherwise (false by default)
     *  * default:         The default value to use when rendering the widget
     *  * title:           The title to use when the widget is rendered
     *  * link:            The link of the widget
     * 
     *  * text:             The text to render in the cell
     *  * filtrable:        Boolean 
     *  * filterType:       Filter type
     *  * fixedConditions:  Conditions to the query
     *  * filterLabel:      Lable of the input filter
     *  * filterItems:      List of items in multi options inputs
     *  * template:         template to render. Must content %text%
     *  * sort:             sorted by this th?
     *  * sortDirection:    sort direction if sort is set
     *  * 
     * 
     * @param array $options     An array of options
     * @param array $attributes  An array of default HTML attributes
     *
     * @see sfWidget
     */
    
    public function __construct($options = array(), $attributes = array())
    {

        $this->addOption('sort', false);     
        $this->addOption('sortable', true);             
        $this->addOption('sortDirection', 'asc');             
      
      parent::__construct($options, $attributes);
    }    


    
    public function setSort() {
          $this->setOption('sort', true);
          return $this;                
    }

    
    
    
    public function getSortDirection() {
        return $this->getOption('sortDirection');
    }

    public function setSortDirection($direction) {
        if(($direction == 'asc') || ($direction == 'desc'))
        {
          $this->setOption('sortDirection', $direction);
        }
        return $this;                    
    }

    public function isSortable() {
      return $this->getOption('sortable');
    }

    public function isSort() {
      return $this->getOption('sort');
    }

    public function setSortable() {
          $this->setOption('sortable', true);
          return $this;                
    }
    
    public function render($content = '') {
        return parent::render();        
    }
    
}


?>
